const get_export_file = async (name, localname) => {
    const response = await fetch(`http://127.0.0.1:8001/docxs/deal/export?name=${name}`);
    const blob = await response.blob();
    const url = window.URL.createObjectURL(blob);
    const a = document.createElement('a');
    a.href = url;
    a.download = localname;
    document.body.appendChild(a);
    a.click();
    document.body.removeChild(a);
    window.URL.revokeObjectURL(url);
};
const  fileToBase64=(file) =>{
  return new Promise((resolve, reject) => {
    const reader = new FileReader();
    reader.readAsDataURL(file); // 读取为 Data URL（Base64）
    reader.onload = () => resolve(reader.result); // 成功时返回 Base64
    reader.onerror = (error) => reject(error); // 失败时抛出错误
  });
}


export { 
    get_export_file,
    fileToBase64
}